<template>
  <div class="ad_content5">
    <div class="title_h1">
      <div>企业动态</div>
      <div class="add_d" @click="addDongtai">
        <div class="iconfont el-icon-circle-plus-outline">新建动态</div>
      </div>
    </div>
    <div class="ad_c5_body">
      <el-table :data="dataList" style="width: 100%" stripe>
        <el-table-column prop="title" label="标题" width="300">
        </el-table-column>
        <el-table-column label="图片" align="center">
          <template slot-scope="scope">
            <div v-if="scope.row.thumbnail">
              <img :src="http + scope.row.thumbnail" class="img2_table" />
            </div>
          </template>
        </el-table-column>

        <el-table-column prop="isshow" label="是否显示" align="center">
        </el-table-column>
        <el-table-column prop="sort" label="排序" align="center">
        </el-table-column>
        <el-table-column prop="time" label="发布日期" width="200">
        </el-table-column>
        <el-table-column label="操作" width="100" align="center">
          <template slot-scope="scope">
            <el-button @click="editItem(scope.row)" type="text" size="small"
              >编辑</el-button
            >
            <el-button @click="delItem(scope.row)" type="text" size="small"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      background
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[50, 100, 300, 400]"
      :page-size="50"
      layout="total, sizes, prev, pager, next, jumper"
      :total="dataList.length"
      class="pagination_pp"
    >
    </el-pagination>
  </div>
</template>

<script>
import { Message } from "element-ui";
export default {
  components: {},
  data() {
    return {
      currentPage4: 1,
      dataList: [],
      http: "",
      currId: "",
    };
  },
  beforeMount() {
    this.http = this.$apiUrl;
    this.init();
  },
  methods: {
    init() {
      this.$getApi("/common/qiyedongtailist", {}).then((res) => {
        console.log(res);
        // this.rfuwenben = res.data.content
        this.dataList = res.data;
      });
    },
    subData() {
      console.log(this.formDa);
    },
    editItem(item) {
      console.log(item);
      this.$router.push({
        path: "/Content5Edit",
        query: { info: item.id },
      });
    },
    addDongtai() {
      this.$router.push({ path: "/Content5Edit" });
    },
    delItem(item) {
      console.log(item);
      this.open();
      this.currId = item.id;
    },
    open() {
      let this_ = this;
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this_
            .$getApi("/common/articledelete", { id: this_.currId })
            .then((res) => {
              console.log(res);
              Message({
                type: "success",
                message: "删除成功",
                showClose: true,
              });
              this_.init();
            });
        })
        .catch(() => {
          Message({
            type: "info",
            message: "已取消删除",
            showClose: true,
          });
        });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
};
</script>

<style scoped lang="stylus">
.img2_table {
  width: 40px;
}

.pagination_pp {
  padding: 10px 10px 10px 26px;
}

.ad_content5 {
  background-color: #fff;
  padding-bottom: 30px;

  .sub_btn {
    display: block;
    width: 300px;
    margin: 30px 0 20px 200px;
  }

  .title_h1 {
    // text-align center;
    display: flex;
    justify-content: space-between;
    color: #004173;
    font-size: 26px;
    padding: 20px 30px 10px 60px;
    border-bottom: 1px solid #f0f0f0;

    .add_d {
      cursor: pointer;
    }
  }

  .ad_c5_body {
    padding: 10px;
  }
}
</style>
